cmake_minimum_required(VERSION 3.7.1)
project(dcsmini)

### 判断是否交叉编译
if (CMAKE_CROSSCOMPILING)
    # 交叉编译
    message(STATUS " >>> Cross compiler")
    # run on imx6ul
    add_definitions(-D__ON_IMX6UL__)
else ()
    # 普通编译
    message(STATUS " >>> Normal compiler")
    # run on x86
    add_definitions(-D__ON_X86__)
endif ()

### 系统兼容性检测
if (APPLE)
    # macOS
    message(STATUS " >>> APPLE")
elseif (CYGWIN)
    message(STATUS " >>> CYGWIN")
elseif (UNIX)
    # Linux
    message(STATUS " >>> UNIX")
endif ()

set(CMAKE_VERBOSE_MAKEFILEON ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

#搜索所有ui设计文件
file(GLOB UI_DESIGN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.ui)

#添加头文件搜索路径
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dcsdb)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dcsmini)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dcsproto)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mqttclient)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/global)

#搜索c和cpp文件
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRCS_UI)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/dcsdb SRCS_DCSDB)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/dcsplayer SRCS_DCSPLAYER)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/dcsproto SRCS_DCSPROTO)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/mqttclient SRCS_MQTTCLIENT)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/utils SRCS_UTILS)

find_package(Qt5 COMPONENTS
        Core
        Gui
        Widgets
        Network
        Sql
        REQUIRED)


add_executable(dcsmini
        ${SRCS_UI}
        ${UI_DESIGN_FILES}
        ${SRCS_DCSDB}
        ${SRCS_DCSPLAYER}
        ${SRCS_DCSPROTO}
        ${SRCS_MQTTCLIENT}
        ${SRCS_UTILS})


target_link_libraries(dcsmini
        Qt5::Core
        Qt5::Gui
        Qt5::Widgets
        Qt5::Network
        Qt5::Sql
        qmqtt
        )

install(TARGETS dcsmini RUNTIME DESTINATION /usr/bin)
